<template>
  <div
    :title="view === 'create'? '新增': '编辑'"
    :visible="true"
    :before-close="closeDialog"
    >
    <el-form :model="formData" label-width="80px" ref="ruleForm" class="diafrom" :rules="rules">
      <el-form-item label="商品名称" prop="productName" required>
        <el-input v-model.trim="formData.productName" auto-complete="off"></el-input>
      </el-form-item>
      <el-form-item label="销售价格" prop="originalPrice" required>
        <el-input v-model.trim="formData.originalPrice" auto-complete="off"></el-input>
      </el-form-item>
      <el-form-item label="市场价" prop="bazaarPrice" required>
        <el-input v-model.trim="formData.bazaarPrice" auto-complete="off"></el-input>
      </el-form-item>
			<el-form-item label="售卖数量" prop="number" required>
        <el-input v-model.trim="formData.number" auto-complete="off"></el-input>
      </el-form-item>
      <el-form-item label="商品类别" prop="categoryNo" required>
        <el-select v-model.trim="formData.categoryNo">
              <el-option 
              	v-for="item in CategoryList"
      					:key="item.id"
      					:label="item.categoryName"
      					:value="item.categoryNo"
      				></el-option>
        </el-select>
      </el-form-item>
			<el-form-item label="规格添加" prop="txt">
        <el-button type="primary" @click="condialogVisible = true">管理规格</el-button>
      </el-form-item>
			<el-form-item label="选择规格组合">
				<el-button type="primary" @click="specVisible">选择规格组合</el-button>
			</el-form-item>	
			<el-form-item label="规格组合列表">
				<el-table
				:data="formData.specList"
				style="width: 100%">
				<el-table-column
					prop="specId"
					label="规格组合id"
					>
				</el-table-column>
				<el-table-column
				prop="specName"
					label="规格组合名称"
					>
				</el-table-column>
					<el-table-column
					label="规格价格"
					>
					<template scope="scope">
					<el-input v-model="scope.row.specPrice" auto-complete="off"></el-input>
				</template>
				</el-table-column>
				<el-table-column label="操作" >
						<template scope="scope">
						<el-button
							size="small"
							type="danger"
							@click="specDelete(scope.$index, scope.row, formData.specList)">删除</el-button>
						</template>
					</el-table-column>
			</el-table>
			</el-form-item>		
      <el-form-item label="兑换规则" prop="productDetails">
         <tinymce  v-model.trim="formData.productDetails"></tinymce>
      </el-form-item>
      <el-form-item label="序号" prop="serialNumber" required>
        <el-input v-model.trim="formData.serialNumber" auto-complete="off"></el-input>
      </el-form-item>
      <el-form-item label="商品类型" prop="productType" required v-if=" view === 'create'">
        <el-select v-model.trim="formData.productType">
          <el-option v-for="(item, index) in ['实物', '彩票','券/虚拟','优惠券']" :value="String(index+1)" :label="item" :key="index"></el-option>
        </el-select>
      </el-form-item>
			<el-form-item label="销售价格" style="display:none" prop="salePrice" required>
        <el-input v-model.trim="formData.salePrice" auto-complete="off"></el-input>
      </el-form-item>
      <el-form-item label="运费" prop="freight">
        <el-input v-model.trim="formData.freight" auto-complete="off"></el-input>
      </el-form-item>
      <el-form-item label="支付方式" prop="payMethod">
        <el-select v-model.trim="formData.payMethod">
          <el-option v-for="(item, index) in ['RMB']" :value="String(index+1)" :label="item" :key="index"></el-option>
        </el-select>
      </el-form-item>
			<el-form-item label="选择优惠券" prop="couponNo" v-if="formData.productType === '4'" required>
        <el-select v-model.trim="formData.couponNo" @change="onSelectedCoupon">
              <el-option 
              	v-for="item in couponList"
      					:key="item.couponNo"
      					:label="item.couponName"
      					:value="item.couponNo"
      				></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="封面图片" prop="coverPicImg">
      	<div class="editImg" v-if="imgShow === 'edit'">
      		<img :src="imgSrc(formData.picUrl)" />
      	</div>
        <el-upload
				  :action="baseUrl()"
				  class="upload-demo"
				  list-type="picture-card"
				  accept="image/jpeg,image/gif,image/png,image/bmp"
				  :on-preview="handlePictureCardPreview"
				  :on-remove="handleRemove"
				  :on-change="handleChangeImg"
				  :auto-upload = "false"
				  :drag="false"
				  >
				  <i class="el-icon-plus"></i>
				   <div slot="tip" class="el-upload__tip">建议尺寸：450*380</div>
				</el-upload>
				<el-dialog :visible.sync="dialogVisible" size="tiny">
				  <img width="100%" :src="dialogImageUrl" alt="">
				</el-dialog>
      </el-form-item>
      <!-- <el-form-item label="上传excel流" v-if="formData.productType === '3'" prop="institutionLogoPic">
        <el-upload
				  class="upload-demo"
				  :action="baseUrl()"
				  :auto-upload = "false"
				  :on-remove="handleRemove"
				  :on-change="handleChange"
				  accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
				  multiple
				  :limit="3"
				  :on-exceed="handleExceed"
				  :file-list="fileList">
				  <el-button size="small" type="primary">点击上传</el-button>
				  <div slot="tip" class="el-upload__tip">只能上传Excel文件</div>
				</el-upload>
      </el-form-item> -->
      <el-form-item label="有效开始时间" v-if="formData.productType === '3'" prop="startDate">
         <div class="block">
				    <el-date-picker
				      v-model="formData.startDate"
				      format="yyyy-MM-dd HH:mm:ss"
				      value-format="yyyy-MM-dd HH:mm:ss"
				      type="datetime"
				      :picker-options="pickerBeginDateBefore"
				      placeholder="选择日期时间">
				    </el-date-picker>
				  </div>
      </el-form-item>
      <el-form-item label="有效期结束时间" v-if="formData.productType === '3'" prop="endDate">
         <div class="block">
				    <el-date-picker
				      v-model="formData.endDate"
				      format="yyyy-MM-dd HH:mm:ss"
				      value-format="yyyy-MM-dd HH:mm:ss"
				      type="datetime"
				      :picker-options="pickerBeginDateAfter"
				      placeholder="选择日期时间">
				    </el-date-picker>
				  </div>
      </el-form-item>
			<el-form-item label="有效开始时间" v-if="formData.productType === '4'" prop="startDate">
        <el-input v-model.trim="formData.startDate" auto-complete="off" readonly="readonly" style="width:193px"></el-input>
      </el-form-item>
			<el-form-item label="有效结束时间" v-if="formData.productType === '4'" prop="endDate">
        <el-input v-model.trim="formData.endDate" auto-complete="off"  readonly="readonly" style="width:193px"></el-input>
      </el-form-item>
      <el-form-item label="结算金额" style="display:none" prop="closingAmt">
        <el-input v-model.trim="formData.closingAmt" auto-complete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="closeDialog">取 消</el-button>
      <el-button type="primary" @click="submit('ruleForm')" :disabled="Subabled">确 定</el-button>
    </div>
			<el-dialog
					title="添加规格"
					:visible="condialogVisible"
					:before-close="handleClose"
					>
					<div>
							<el-form :inline="true" ref="formFilter">
								<el-form-item>
									<el-button style="float: right;" type="primary" @click="create">新增</el-button>
								</el-form-item>
							</el-form>
						</div>
					<div class="content">
					<div class="left_content">
						<el-tree :data="tree" 
							node-key="id"
							@check-change="handleCheckChange"
							ref="tree">
						</el-tree>
					</div>
					<div class="right_content">
						<el-table
							v-loading.body="loading"
							:data="tableData"
							border
							style="width: 100%">
							<el-table-column
								prop="id"
								label="规格id">
							</el-table-column>
							<el-table-column
								prop="specName"
								label="规格名称">
							</el-table-column>
							<el-table-column
								prop="parentId"
								label="上级规格id">
							</el-table-column>
							<el-table-column
								label="上级规格名称">
								<template scope="scope">
									{{ scope.row.parentName || "一级标签" }}
								</template>
							</el-table-column>
							<el-table-column label="操作" width="150">
								<template scope="scope">
									<el-button
										:disabled="scope.row.status === '1'?true:false"
										size="small"
										@click="handleEdit(scope.$index, scope.row)">编辑</el-button>
									<el-button
										:disabled="scope.row.status === '1'?true:false"
										size="small"
										type="danger"
										@click="handleDelete(scope.$index, scope.row, tableData)">删除</el-button>
									</template>
							</el-table-column>
						</el-table>
					</div>
					</div>
					<span slot="footer" class="dialog-footer">
							<el-button @click="condialogVisible = false">取 消</el-button>
					</span>
			</el-dialog>
			<edit-spec
      ref="edit-spec"
      @close="editFinish"
      :view="showview"
      v-if="showview ==='create' || showview ==='edit'"/>
			<edit-comb
      ref="edit-comb"
      @close="editFinish"
			@succback="specFinish"
      :view="combview"
      v-if="combview ==='open'"/>
  </div>
	
</template>

<script>
import { queryAllCategory,queryCouponinfo } from "@/services/product";
import { queryspec,query,create,edit,del } from "@/services/spec";
import { RequestError } from "@/services/errors";
import { md5 } from '@/utilities/crypto' // 加密
import { mapActions } from "vuex";
import {deepClone} from '@/utilities/object'
import EditSpec from './specedit'
import EditComb from './combedit'
import Tinymce from "@/components/Tinymce";
var vailMoney = (rule, value, callback) => {
	var MoneyRegex = /^(0|([1-9]\d{0,8}))(\.\d{1,2})?$/;
	if (!MoneyRegex.test(value)) {
	    callback(new Error('数字格式不正确,最多可输入两位小数'))
	    } else {
	        callback();
	    }
};
var vailNumber = (rule, value, callback) => {
	var NumberyRegex = /^[0-9]*$/;
	if (!NumberyRegex.test(value)) {
	    callback(new Error('格式不正确,只能输入数字'))
	    } else {
	        callback();
	    }
};

export default {
  name: "edit-role",
	components: {Tinymce,EditSpec,EditComb},
  data () {
    return {
			condialogVisible: false,
			showview: '',
			combview:'',
			loading: false,
			tableData: [],
			fileList:[],
			file:[],
      CategoryList:[],
			couponList:[],
      imgShow:"",
			Subabled:false,
      formData: {
        productName: "",
				originalPrice: "",
				number:"",
        bazaarPrice:"",
        categoryNo: "",
        productDetails:"",
        serialNumber:"",
        productType:"",
        salePrice:"",
        freight:"",
        payMethod:"",
				couponNo:"",
        startDate:"",
        endDate:"",
				closingAmt:"",
				specList:[
        ]
      },
			tree:[],
      dialogImageUrl: '',
      dialogVisible: false,
      dialogFormVisible: false,
      pickerBeginDateBefore:{
            disabledDate: (time) => {
                let beginDateVal = this.formData.endDate;
                if (beginDateVal) {
                    return time.getTime() > beginDateVal;
                }
            }
			},
			pickerBeginDateAfter:{
					disabledDate: (time) => {
							let beginDateVal = this.formData.startDate;
							if (beginDateVal) {
									return time.getTime() < beginDateVal;
							}
					}
			},
      rules: {
        productName: [{ required: true, message: "请输入商品名称", trigger: "blur" },
         { min: 1, max: 50, message: '长度在 50个字符以内', trigger: 'blur' }],
         //两位有效数字
        originalPrice: [{ required: true, message: "请输入商品原价", trigger: 'blur'},
        { min: 1, max: 12, message: '长度在 12个字符以内', trigger: 'blur' },
        { validator: vailMoney, trigger: 'blur'}],
        bazaarPrice: [{ required: true, message: "请输入市场价", trigger: 'blur'},
        { min: 1, max: 12, message: '长度在 12个字符以内', trigger: 'blur' },
        { validator: vailMoney, trigger: 'blur'}],
        categoryNo: [{ required: true, message: "请选择商品类别", trigger: 'change' }],
        productDetails: [{ required: false, message: "请输入兑换规则", trigger: "blur" }],
        serialNumber: [{ required: true, message: "请输入序号", trigger: "blur" },
        { min: 1, max: 11, message: '长度在 11个字符以内', trigger: 'blur' },
				 { validator: vailNumber, trigger: 'blur'}],
				 number: [{ required: true, message: "请输入数量", trigger: "blur" },
        { min: 1, max: 11, message: '长度在 11个字符以内', trigger: 'blur' },
   			{ validator: vailNumber, trigger: 'blur'}],
        productType: [{ required: true, message: "请选择商品类型", trigger: 'change' }],
        //两位有效数字
        // salePrice: [{ required: true, message: "请输入销售价格", trigger: "blur" },
        // { min: 1, max: 12, message: '长度在 12个字符以内', trigger: 'blur' },
        // { validator: vailMoney, trigger: 'blur'}],
        //两位有效数字
        freight: [{ required: false, message: "请输入运费", trigger: "blur" },
        { min: 1, max: 12, message: '长度在 12个字符以内', trigger: 'blur' },
        { validator: vailMoney, trigger: 'blur'}],
        payMethod: [{ required: true, message: "请选择支付方式", trigger: "change" }],
        // closingAmt: [{ required: false, message: "请输入结算金额", trigger: "blur" },
        // { min: 1, max: 12, message: '长度在 12个字符以内', trigger: 'blur' },
        // { validator: vailMoney, trigger: 'blur'}],
      }
    }
  },
  props: {
    view: {
      type: String,
      default: "create"
    }
  },
  methods: {
    ...mapActions(["setUserInfo"]),
    closeDialog() {
      this.$emit("close");
		},
		handleClose(done) {
				this.condialogVisible = false;
    },
    baseUrl(){
    	return "api/console/product/addInfo.do";
    },
    imgSrc(data){
      	return this.$store.state.imgUrl + data;
    },
    handleRemove(file, fileList) {
    	console.log(file, fileList);
 	  },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
    },
    handleChangeImg(file,fileList){
    	this.imgShow = ""
    	  if(fileList.length > 1){
	    		this.$message.warning('当前限制选择 1个文件,多张图片覆盖第一张');
	    		var thisNode = document.getElementsByClassName("el-upload-list__item")[0];
	    		thisNode.parentNode.removeChild(thisNode);
	    	}
    	  var isJPG = ""
    	  if(file.raw.type === 'image/jpeg' || file.raw.type === 'image/png'){
    		  isJPG = true
    	  }else{
    		  isJPG = false
    	  }
        const isLt2M = file.size / 1024 / 1024 < 2;

        if (!isJPG) {
          this.$message.error('上传图片只能是 JPG/png 格式!');
        }
        if (!isLt2M) {
          this.$message.error('上传图片大小不能超过 2MB!');
        }
        return isJPG && isLt2M;
    },
    handleChange(file,fileList){
    	  if(fileList.length > 1){
    	  	if(document.getElementsByClassName("el-upload-list__item")[0].firstChild.nodeName === 'IMG'){
    	  		this.$message.warning('当前限制选择 1个文件,多个文件覆盖第一个');
		    		var thisNode = document.getElementsByClassName("el-upload-list__item")[1];
		    		thisNode.parentNode.removeChild(thisNode);
    	  	}else{
    	  		this.$message.warning('当前限制选择 1个文件,多个文件覆盖第一个');
		    		var thisNode = document.getElementsByClassName("el-upload-list__item")[0];
		    		thisNode.parentNode.removeChild(thisNode);
    	  	}
	    	}
    	  var isEXL = ""
    	  if(file.raw.type === 'application/vnd.ms-excel' || file.raw.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'){
    		  isEXL = true
    	  }else{
    		  isEXL = false
    	  }
        const isLt2M = file.size / 1024 / 1024 < 2;
        if (!isEXL) {
          this.$message.error('只能上传Excel文档!');
        }
        if (!isLt2M) {
          this.$message.error('上传Excel文档大小不能超过 2MB!');
        }
        return isEXL && isLt2M;
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
		},
		handleCheckChange(data, checked, indeterminate) {
			// 树形控件
				// let myarr =this.$refs.tree.getCheckedNodes()
        // this.formData.specList = myarr;
		},
		editFinish (needRefresh) {
				this.showview = ''
				this.combview = ''
        if (needRefresh) {
					this.loadData();
					this.queryTree();
        }
		},
		specFinish(params){
				// this.specfromData = params;
				this.formData.specList.push(params)
		},
		onSelectedCoupon(data){
			for(let item of this.couponList) {  
					if(item.couponNo == data){
						this.formData.startDate = item.validatyBegin
            this.formData.endDate = item.validatyEnd
					}
			}
		},
		async specVisible () {
        this.combview = 'open'
        await this.$nextTick()
        this.$refs['edit-comb'].loadSelect()
    },
		async create () {
        this.showview = 'create'
        await this.$nextTick()
        this.$refs['edit-spec'].loadSelect()
    },
		async handleEdit (index, data) {
			// debugger
			this.showview = 'edit'
			await this.$nextTick()
			this.$refs['edit-spec'].dialogFormVisible = true
			this.$refs['edit-spec'].loadSelect();
			this.$refs['edit-spec'].formData = deepClone(data)
			this.$refs['edit-spec'].id = data.id
		},
		async queryTree(){
        let data = await queryspec();
        this.tree = data.specList;
		},
		async loadData () {
        this.loading = true
        try {
          let data = await query(Object.assign({currentPage: this.currentPage},{perPage:10},this.formFilter))
          // debugger
          this.tableData = data.specList
          this.pageSize = parseInt(data.totalResult)
        } catch (e) {
          if (e instanceof RequestError) {
            this.$alert(e.message, '提示', {
              type: 'error',
              confirmButtonText: '确定'
            })
          } else {
            throw e
          }
        }
        this.loading = false
      },
    async loadCategory () {
        try {
          let data = await queryAllCategory()
          this.CategoryList = data
        } catch (e) {
          if (e instanceof RequestError) {
            this.$alert(e.message, '提示', {
              type: 'error',
              confirmButtonText: '确定'
            })
          } else {
            throw e
          }
        }
        this.loading = false
		},
		async loadCoupon () {
        try {
          let data = await queryCouponinfo()
          this.couponList = data.data
        } catch (e) {
          if (e instanceof RequestError) {
            this.$alert(e.message, '提示', {
              type: 'error',
              confirmButtonText: '确定'
            })
          } else {
            throw e
          }
        }
        this.loading = false
		},
		specDelete(index, data, rows){
			this.$confirm(`此操作将删除${data.specName}, 是否继续?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async () => {
						rows.splice(index, 1)
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
		},
		handleDelete (index, data, rows) {
        this.$confirm(`此操作将删除${data.specName}, 是否继续?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async () => {
          try {
            await del(data.id)
            this.$message({
              type: 'success',
              message: '已删除'
            })
						rows.splice(index, 1)
						this.queryTree();
          } catch (e) {
            if (e instanceof RequestError) {
              this.$alert(e.message, '提示', {
                type: 'error',
                confirmButtonText: '确定'
              })
            } else {
              throw e
            }
          }
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
      },
    formatDateTime (date) {  
		  var y = date.getFullYear();  
		  var m = date.getMonth() + 1;  
		  m = m < 10 ? ('0' + m) : m;  
		  var d = date.getDate();  
		  d = d < 10 ? ('0' + d) : d;  
		  var h = date.getHours();  
		  h=h < 10 ? ('0' + h) : h;  
		  var minute = date.getMinutes();
		  minute = minute < 10 ? ('0' + minute) : minute;  
		  var second=date.getSeconds();  
		  second=second < 10 ? ('0' + second) : second;  
		  return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;  
		},
    submit(formName) {
    	this.Subabled = true;
      this.$refs[formName].validate(async valid => {
        if (valid) {
          try {
            if (this.view === "create") {
            	//把图片的信息和参数放进请求头里
							let reg = RegExp(/T/);
	            	if(JSON.stringify(this.formData.startDate).match(reg)){
	            		this.formData.startDate = this.formatDateTime(this.formData.startDate);
	            	}
	            	if(JSON.stringify(this.formData.endDate).match(reg)){
	            		this.formData.endDate = this.formatDateTime(this.formData.endDate);
	            	}
            	this.getFromData({
				        productName: this.formData.productName,
								originalPrice: this.formData.originalPrice,
								number:this.formData.number,
				        bazaarPrice:this.formData.bazaarPrice,
				        categoryNo: this.formData.categoryNo,
				        productDetails:this.formData.productDetails,
				        serialNumber:this.formData.serialNumber,
				        productType:this.formData.productType,
				        salePrice:this.formData.originalPrice,
				        freight:this.formData.freight,
				        payMethod:this.formData.payMethod,
				        startDate:this.formData.startDate,
				        endDate:this.formData.endDate,
								closingAmt:this.formData.originalPrice,
								specList:this.formData.specList,
								couponNo:this.formData.couponNo
				      },"/ecshop/console/product/addInfo.do");
            } 
            else {
								let reg = RegExp(/T/);
	            	if(JSON.stringify(this.formData.startDate).match(reg)){
	            		this.formData.startDate = this.formatDateTime(this.formData.startDate);
	            	}
	            	if(JSON.stringify(this.formData.endDate).match(reg)){
	            		this.formData.endDate = this.formatDateTime(this.formData.endDate);
	            	}
              this.getFromData({
              	id: this.formData.id,
				        productName: this.formData.productName,
								originalPrice: this.formData.originalPrice,
								number:this.formData.number,
				        bazaarPrice:this.formData.bazaarPrice,
				        categoryNo: this.formData.categoryNo,
				        productDetails:this.formData.productDetails,
				        serialNumber:this.formData.serialNumber,
				        productType:this.formData.productType,
				        salePrice:this.formData.originalPrice,
				        freight:this.formData.freight,
				        payMethod:this.formData.payMethod,
				        startDate:this.formData.startDate,
				        endDate:this.formData.endDate,
								closingAmt:this.formData.originalPrice,
								specList:this.formData.specList,
								couponNo:this.formData.couponNo
				      },"/ecshop/console/product/updateInfo.do");
				      
            }
            this.dialogFormVisible = false;
          } catch (e) {
            if (e instanceof RequestError) {
              this.$alert(e.message, "提示", {
                type: "error",
                confirmButtonText: "确定"
              });
            } else {
              throw e;
            }
          }
        } else {
          return;
        }
      });
    },
    signature(data) {
		  return md5(data)
		},
		getFromData(dataObj,setUrl){
			let formData = new FormData();
    	let data = dataObj
    	let token = sessionStorage.getItem('token');
    	let  a = new Date();
		  let btime= a .getTime();
			var signs = "data="+JSON.stringify(data)+"&stmb="+btime;
			var oReq = new XMLHttpRequest();
			// if(data.productType != "3"){
			// 	let length = document.getElementsByClassName("el-upload__input").length
			// 		formData.append("coverPicImg", document.getElementsByClassName("el-upload__input")[length-1].files[0]);
			// }else{
			// 	let length = document.getElementsByClassName("el-upload__input").length
			// 	  formData.append("coverPicImg", document.getElementsByClassName("el-upload__input")[length-2].files[0]);
			// 	  formData.append("fileExcel", document.getElementsByClassName("el-upload__input")[length-1].files[0]);
			// }
				let length = document.getElementsByClassName("el-upload__input").length
		 		formData.append("coverPicImg", document.getElementsByClassName("el-upload__input")[length-1].files[0]);
	      formData.append("data", JSON.stringify(data));
	      formData.append("version", "");
	      formData.append("token", token);
	      formData.append("stmb", btime);
	      formData.append('sign', this.signature(signs))
	      oReq.open("POST", setUrl, true);
			oReq.send(formData);
			oReq.onreadystatechange = () => {//在这里指定上传成功的回调函数，接受返回值  
            if (oReq.readyState == 4 && oReq.status == 200) {  
                let res = JSON.parse(oReq.responseText);  
                if(res.rspCode){
                	if(res.rspCode == "0000"){
                	this.$message({
			              showClose: true,
			              message: "提交成功",
			              type: "success"
			            });
			            this.Subabled = false;
			            this.$emit("close", true);
	                }else if(res.rspCode == "1111"){
	                	this.$message({
				              showClose: true,
				              message: "服务器异常，请联系管理员或稍后再试!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "1998"){
	                	this.$message({
				              showClose: true,
				              message: "参数非法!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "1999"){
	                	this.$message({
				              showClose: true,
				              message: "会话超时!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "3333"){
	                	this.$message({
				              showClose: true,
				              message: "参数缺失!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "4444"){
	                	this.$message({
				              showClose: true,
				              message: "请求不合理!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "4000"){
	                	this.$message({
				              showClose: true,
				              message: "上传的文件不存在!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "5000"){
	                	this.$message({
				              showClose: true,
				              message: "token失效，需要重新登入!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "5001"){
	                	this.$message({
				              showClose: true,
				              message: "没有权限!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "5002"){
	                	this.$message({
				              showClose: true,
				              message: "角色已经存在!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "5003"){
	                	this.$message({
				              showClose: true,
				              message: "角色已经使用!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "5203"){
	                	this.$message({
				              showClose: true,
				              message: "查询出来的数据过大，无法导出!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "5004"){
	                	this.$message({
				              showClose: true,
				              message: "用户锁定!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "5005"){
	                	this.$message({
				              showClose: true,
				              message: "菜单不存在!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "5006"){
	                	this.$message({
				              showClose: true,
				              message: "用户密码错误!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "5007"){
	                	this.$message({
				              showClose: true,
				              message: "用户名已存在!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "5007"){
	                	this.$message({
				              showClose: true,
				              message: "用户名已存在!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "5008"){
	                	this.$message({
				              showClose: true,
				              message: "菜单添加失败!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "5009"){
	                	this.$message({
				              showClose: true,
				              message: "权限失败!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "5010"){
	                	this.$message({
				              showClose: true,
				              message: "输入的原密码错误!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "5011"){
	                	this.$message({
				              showClose: true,
				              message: "输入的权限菜单为空!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "6001"){
	                	this.$message({
				              showClose: true,
				              message: "商品信息不存在!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "6002"){
	                	this.$message({
				              showClose: true,
				              message: "商品不是实物!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "6003"){
	                	this.$message({
				              showClose: true,
				              message: "商品名称已经存在了!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "6004"){
	                	this.$message({
				              showClose: true,
				              message: "上传的文件不存在!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "6005"){
	                	this.$message({
				              showClose: true,
				              message: "上传的文件数量错误!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "6006"){
	                	this.$message({
				              showClose: true,
				              message: "上传的文件xls不存在!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "6007"){
	                	this.$message({
				              showClose: true,
				              message: "商品库存还有可用数量!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "6008"){
	                	this.$message({
				              showClose: true,
				              message: "商品库存没有可用数量!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "6009"){
	                	this.$message({
				              showClose: true,
				              message: "开始时间不能大于结束时间!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "6101"){
	                	this.$message({
				              showClose: true,
				              message: "机构名称已经存在!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "6102"){
	                	this.$message({
				              showClose: true,
				              message: "上传的图片不存在!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "6103"){
	                	this.$message({
				              showClose: true,
				              message: "banner名称已经存在!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "6104"){
	                	this.$message({
				              showClose: true,
				              message: "上传的图片不存在!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "6201"){
	                	this.$message({
				              showClose: true,
				              message: "查询的信息无效!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "6301"){
	                	this.$message({
				              showClose: true,
				              message: "商户名称已经存在!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "6302"){
	                	this.$message({
				              showClose: true,
				              message: "商户用户名称已经存在!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }else if(res.rspCode == "6303"){
	                	this.$message({
				              showClose: true,
				              message: "商户信息不存在!",
				              type: "error"
				            });
				            this.Subabled = false;
	                }
                }
            }
        };
		}
  },
  mounted() {}
};
</script>
<style>
.diafrom{
	width: 100%;
	float: left;
}
.el-dialog{
   z-index: 99;
}
.el-select {
  width: 100%;
}
.editImg{
	  overflow: hidden;
    background-color: #fff;
    border: 1px solid #c0ccda;
    border-radius: 6px;
    box-sizing: border-box;
    width: 148px;
    height: 148px;
    margin: 0 8px 8px 0;
    display: inline-block;
    float: left;
}
.editImg img{
	width: 100%;
	height: 100%;
}
</style>
